
clear
set more off

global dirtables ""
global dirgeolocalized ""
global dirtaximeter ""

use "$dirgeolocalized/collapsed_uber_censo_lessthan500mts.dta", clear
keep year ID  fare_price_card fare_price_cash distance_price_card distance_price_cash distance_mts_o_d_card distance_mts_o_d_cash  driving_mts_card driving_mts_cash trips_card fares_card trips_cash fares_cash dist_to_edomex dist_to_df id ///
CVE_ENT NOM_ENT CVE_MUN NOM_MUN CVE_LOC NOM_LOC CVE_AGEB CVE_MZA x_centroid y_centroid ///
POBTOT VIVTOT REL_H_M PROM_HNV GRAPROES  PNACENT P3YM_HLI PHOG_IND PCON_LIM PEA PEA_M ///
PEA_F P12YM_CASA VPH_PISOTI VPH_1DOR VPH_1CUART VPH_S_ELEC VPH_AGUAFV VPH_NODREN VPH_EXCSA  ///
VPH_SNBIEN VPH_AUTOM VPH_CEL VPH_INTER GRAPROES_M GRAPROES_F max_distance_mts* mean_distance_mts*

drop if year==2018
egen trips=rowtotal(trips_card trips_cash)
egen fares=rowtotal(fares_card fares_cash)
egen miles=rowtotal(distance_mts_o_d_card distance_mts_o_d_cash)
egen miles_driving=rowtotal(driving_mts_card driving_mts_cash)

egen fares_price=rowtotal(fare_price_card fare_price_cash)
egen distance_price=rowtotal(distance_price_card distance_price_cash)
gen price=fares_price/distance_price

replace miles=miles/1000
replace miles_driving=miles_driving/1000

gen share_cash=fares_cash/fares
keep if POBTOT>0 &  VIVTOT>0
gen distance=dist_to_df
replace distance=-dist_to_edomex if CVE_ENT=="09"
replace distance=distance/1000

keep if abs(distance)<20
gen temp_trips2016=trips if year==2016
bysort ID: egen trips2016=max(temp_trips2016)
replace trips2016=trips2016/POBTOT

foreach var in trips2016 PNACENT P3YM_HLI PHOG_IND PCON_LIM PEA PEA_M PEA_F P12YM_CASA {
gen s`var'=`var'/POBTOT
}

foreach var in VPH_PISOTI VPH_1DOR VPH_1CUART VPH_S_ELEC VPH_AGUAFV VPH_NODREN VPH_EXCSA VPH_SNBIEN VPH_AUTOM VPH_CEL VPH_INTER {
gen s`var'=`var'/VIVTOT
}

tsset ID year
tsfill, full
by ID: carryforward CVE_ENT CVE_MUN CVE_LOC CVE_AGEB CVE_MZA, replace

foreach var in trips fares trips_card fares_card  trips_cash fares_cash {
replace `var'=0 if `var'==.
}

capture drop d_trips* d_fares*
gen d_trips=2*(trips-l.trips)/(trips+l.trips)
gen d_fares=2*(fares-l.fares)/(fares+l.fares)
gen d_trips_card=2*(trips_card-l.trips_card)/(trips_card+l.trips_card)
gen d_fares_card=2*(fares_card-l.fares_card)/(fares_card+l.fares_card)
gen d_price=2*(price-l.price)/(price+l.price)

gen T1T0=trips*l.trips
gen DW_I=d_trips if d_trips!=2 & d_trips!=-2 & (d_trips!=0 & T1T0>0)
replace DW_I=0 if T1T0==0
gen DW_E=d_trips if d_trips==2 | d_trips==-2 | (d_trips==0 & T1T0>0)
replace DW_E=0 if DW_E==. & DW_I!=.
replace DW_I=0 if DW_I==. & DW_E!=.
replace DW_E=. if d_trips==.
replace DW_I=. if d_trips==.
gen DW=DW_I + DW_E
count if DW!=d_trips & year==2017

gen T1T0_card=trips_card*l.trips_card
gen DW_I_card=d_trips_card if d_trips_card!=2 & d_trips_card!=-2 & (d_trips_card!=0 & T1T0_card>0)
replace DW_I_card=0 if T1T0_card==0
gen DW_E_card=d_trips_card if d_trips_card==2 | d_trips_card==-2 | (d_trips_card==0 & T1T0_card>0)
replace DW_E_card=0 if DW_E_card==. & DW_I_card!=.
replace DW_I_card=0 if DW_I_card==. & DW_E_card!=.
replace DW_E_card=. if d_trips_card==.
replace DW_I_card=. if d_trips_card==.
gen DW_card=DW_I_card + DW_E_card
count if DW_card!=d_trips_card & year==2017

gen T1T0_fares=fares*l.fares
gen DW_I_fares=d_fares if d_fares!=2 & d_fares!=-2 & (d_fares!=0 & T1T0_fares>0)
replace DW_I_fares=0 if T1T0==0
gen DW_E_fares=d_fares if d_fares==2 | d_fares==-2 | (d_fares==0 & T1T0_fares>0)
replace DW_E_fares=0 if DW_E_fares==. & DW_I_fares!=.
replace DW_I_fares=0 if DW_I_fares==. & DW_E_fares!=.
replace DW_E_fares=. if d_fares==.
replace DW_I_fares=. if d_fares==.
gen DW_fares=DW_I_fares + DW_E_fares
replace DW_fares=. if d_fares==.
count if DW_fares!=d_fares & year==2017


gen T1T0_fares_card=fares_card*l.fares_card
gen DW_I_fares_card=d_fares_card if d_fares_card!=2 & d_fares_card!=-2 & (d_fares_card!=0 & T1T0_fares_card>0)
replace DW_I_fares_card=0 if T1T0_card==0
gen DW_E_fares_card=d_fares_card if d_fares_card==2 | d_fares_card==-2 | (d_fares_card==0 & T1T0_fares_card>0)
replace DW_E_fares_card=0 if DW_E_fares_card==. & DW_I_fares_card!=.
replace DW_I_fares_card=0 if DW_I_fares_card==. & DW_E_fares_card!=.
replace DW_E_fares_card=. if d_fares_card==.
replace DW_I_fares_card=. if d_fares_card==.
gen DW_fares_card=DW_I_fares_card + DW_E_fares_card
replace DW_fares_card=. if d_fares_card==.
count if DW_fares_card!=d_fares_card & year==2017


keep if year==2017
gen treatment=(CVE_ENT=="15")
reg d_price treatment  

merge 1:1 CVE_ENT CVE_MUN CVE_LOC CVE_AGEB CVE_MZA using "$dirgeolocalized/denue_bancos.dta"
drop if _merge==2
drop _merge
replace count_banks=0 if count_banks==.
gen bank=(count_banks!=0 & count_banks!=.)

egen ageb_id=group(CVE_ENT CVE_MUN CVE_AGEB)

label variable treatment "State of Mexico"
foreach var in sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM {
bysort CVE_ENT: egen m`var'=mean(`var')
}

tsset ID year

cem count_banks GRAPROES sPEA sVPH_CEL sVPH_INTER sVPH_AUTOM, treatment(treatment) showbreaks 

reg d_trips treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table1.tex", keep(treatment) ///
	tex nocons replace bdec(3) tdec(3)  ctitle("$\Delta Trips$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, All) label nonotes  
	
reg DW_I treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table1.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Trips_I$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, Intensive) label nonotes

reg DW_E treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table1.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Trips_E$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, Extensive) label nonotes
	
reg d_fares treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table1.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Fares$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, All) label nonotes
	
reg DW_I_fares treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table1.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Fares_I$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, Intensive) label nonotes

reg DW_E_fares treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table1.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Fares_E$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, Extensive) label nonotes

reg d_price treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table1.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Price$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, All) label nonotes
	



reg d_trips_card treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table2.tex", keep(treatment) ///
	tex nocons replace bdec(3) tdec(3)  ctitle("$\Delta Trips^{card}$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, All) label nonotes
	
reg DW_I_card treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table2.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Trips^{card}_I$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, Intensive) label nonotes

reg DW_E_card treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table2.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Trips^{card}_E$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, Extensive) label nonotes
	
reg d_fares_card treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table2.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Fares^{card}$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, All) label nonotes
	
reg DW_I_fares_card treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table2.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Fares^{card}_I$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, Intensive) label nonotes

reg DW_E_fares_card treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table2.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Fares^{card}_E$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, Extensive) label nonotes
	


use "$dirgeolocalized/collapsed_uber_censo_lessthan500mts.dta", clear
keep year ID distance_price_card distance_price_cash fare_price_card fare_price_cash trips_card fares_card trips_cash fares_cash dist_to_edomex  driving_mts_card driving_mts_cash dist_to_df id ///
CVE_ENT NOM_ENT CVE_MUN NOM_MUN CVE_LOC NOM_LOC CVE_AGEB CVE_MZA x_centroid y_centroid ///
POBTOT VIVTOT REL_H_M PROM_HNV GRAPROES  PNACENT P3YM_HLI PHOG_IND PCON_LIM PEA PEA_M ///
PEA_F P12YM_CASA VPH_PISOTI VPH_1DOR VPH_1CUART VPH_S_ELEC VPH_AGUAFV VPH_NODREN VPH_EXCSA  ///
VPH_SNBIEN VPH_AUTOM VPH_CEL VPH_INTER GRAPROES_M GRAPROES_F max_distance_mts* mean_distance_mts*

drop if year==2018
egen trips=rowtotal(trips_card trips_cash)
egen fares=rowtotal(fares_card fares_cash)
gen share_cash=fares_cash/fares
keep if POBTOT>0 &  VIVTOT>0
gen distance=dist_to_df
replace distance=-dist_to_edomex if CVE_ENT=="09"
replace distance=distance/1000


egen fares_price=rowtotal(fare_price_card fare_price_cash)
egen distance_price=rowtotal(distance_price_card distance_price_cash)
gen price=fares_price/distance_price


keep if abs(distance)<20
gen temp_trips2016=trips if year==2016
bysort ID: egen trips2016=max(temp_trips2016)
replace trips2016=trips2016/POBTOT

foreach var in trips2016 PNACENT P3YM_HLI PHOG_IND PCON_LIM PEA PEA_M PEA_F P12YM_CASA {
gen s`var'=`var'/POBTOT
}

foreach var in VPH_PISOTI VPH_1DOR VPH_1CUART VPH_S_ELEC VPH_AGUAFV VPH_NODREN VPH_EXCSA VPH_SNBIEN VPH_AUTOM VPH_CEL VPH_INTER {
gen s`var'=`var'/VIVTOT
}

tsset ID year
tsfill, full
by ID: carryforward CVE_ENT CVE_MUN CVE_LOC CVE_AGEB CVE_MZA, replace

foreach var in trips fares {
replace `var'=0 if `var'==.
}

capture drop d_trips d_fares
gen d_trips=2*(trips-l.trips)/(trips+l.trips)
gen d_fares=2*(fares-l.fares)/(fares+l.fares)
gen d_trips_card=2*(trips_card-l.trips_card)/(trips_card+l.trips_card)
gen d_fares_card=2*(fares_card-l.fares_card)/(fares_card+l.fares_card)
gen d_price=2*(price-l.price)/(price+l.price)


keep if year==2017
gen treatment=(CVE_ENT=="15")

merge 1:1 CVE_ENT CVE_MUN CVE_LOC CVE_AGEB CVE_MZA using "$dirgeolocalized/denue_bancos.dta"
drop if _merge==2
drop _merge
replace count_banks=0 if count_banks==.
gen bank=(count_banks!=0 & count_banks!=.)

egen ageb_id=group(CVE_ENT CVE_MUN CVE_AGEB)

label variable treatment "State of Mexico"

gen distance2=distance*distance
gen distance3=distance2*distance
gen distance4=distance3*distance
gen distance5=distance4*distance
gen EDOMEX=treatment
gen EDOMEXxdistance=EDOMEX*distance
gen EDOMEXxdistance2=EDOMEX*distance2
gen EDOMEXxdistance3=EDOMEX*distance3
gen EDOMEXxdistance4=EDOMEX*distance4
gen EDOMEXxdistance5=EDOMEX*distance5
label variable EDOMEX "State of Mexico"

foreach var in sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM {
bysort CVE_ENT: egen m`var'=mean(`var')
}	


reg d_trips EDOMEX distance EDOMEXxdistance sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM, vce(cluster ageb_id)
	outreg2 using "$dirtables/Table3.tex", keep(EDOMEX) ///
	tex nocons replace bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 1) label nonotes
estat ic
reg d_trips EDOMEX distance distance2 EDOMEXxdistance EDOMEXxdistance2 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM, vce(cluster ageb_id)
	outreg2 using "$dirtables/Table3.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 2) label nonotes
estat ic
reg d_trips EDOMEX distance distance2 distance3 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM, vce(cluster ageb_id)
	outreg2 using "$dirtables/Table3.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 3) label nonotes
estat ic
reg d_trips EDOMEX distance distance2 distance3 distance4 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 EDOMEXxdistance4  sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM, vce(cluster ageb_id)
	outreg2 using "$dirtables/Table3.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 4) label nonotes
estat ic
reg d_trips EDOMEX distance distance2 distance3 distance4 distance5 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 EDOMEXxdistance4 EDOMEXxdistance5 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM, vce(cluster ageb_id)
	outreg2 using "$dirtables/Table3.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 5) label nonotes
estat ic


reg d_fares EDOMEX distance EDOMEXxdistance sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM, vce(cluster ageb_id)
	outreg2 using "$dirtables/Table4.tex", keep(EDOMEX) ///
	tex nocons replace bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 1) label nonotes
estat ic
reg d_fares EDOMEX distance distance2 EDOMEXxdistance EDOMEXxdistance2 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM, vce(cluster ageb_id)
	outreg2 using "$dirtables/Table4.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 2) label nonotes
estat ic
reg d_fares EDOMEX distance distance2 distance3 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM, vce(cluster ageb_id)
	outreg2 using "$dirtables/Table4.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 3) label nonotes
estat ic
reg d_fares EDOMEX distance distance2 distance3 distance4 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 EDOMEXxdistance4  sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM, vce(cluster ageb_id)
	outreg2 using "$dirtables/Table4.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 4) label nonotes
estat ic
reg d_fares EDOMEX distance distance2 distance3 distance4 distance5 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 EDOMEXxdistance4 EDOMEXxdistance5 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM, vce(cluster ageb_id)
	outreg2 using "$dirtables/Table4.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 5) label nonotes
estat ic

reg d_trips EDOMEX distance EDOMEXxdistance sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)<5, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC1.tex", keep(EDOMEX) ///
	tex nocons replace bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, <5 Km, Degree, 1) label nonotes
estat ic
reg d_trips EDOMEX distance distance2 EDOMEXxdistance EDOMEXxdistance2 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)<5, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC1.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, <5 Km, Degree, 2) label nonotes
estat ic
reg d_trips EDOMEX distance distance2 distance3 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)<5, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC1.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, <5 Km, Degree, 3) label nonotes
estat ic
reg d_trips EDOMEX distance distance2 distance3 distance4 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 EDOMEXxdistance4 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)<5, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC1.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, <5 Km, Degree, 4) label nonotes
estat ic
reg d_trips EDOMEX distance distance2 distance3 distance4 distance5 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 EDOMEXxdistance4 EDOMEXxdistance5 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)<5, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC1.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, <5 Km, Degree, 5) label nonotes
estat ic


reg d_fares EDOMEX distance EDOMEXxdistance sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)<5, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC2.tex", keep(EDOMEX) ///
	tex nocons replace bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, <5 Km, Degree, 1) label nonotes
estat ic
reg d_fares EDOMEX distance distance2 EDOMEXxdistance EDOMEXxdistance2 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)<5, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC2.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, <5 Km, Degree, 2) label nonotes
estat ic
reg d_fares EDOMEX distance distance2 distance3 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)<5, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC2.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, <5 Km, Degree, 3) label nonotes
estat ic
reg d_fares EDOMEX distance distance2 distance3 distance4 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 EDOMEXxdistance4 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)<5, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC2.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, <5 Km, Degree, 4) label nonotes
estat ic
reg d_fares EDOMEX distance distance2 distance3 distance4 distance5 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 EDOMEXxdistance4 EDOMEXxdistance5 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)<5, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC2.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, <5 Km, Degree, 5) label nonotes
estat ic


reg d_trips EDOMEX distance EDOMEXxdistance sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)>.1, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC3.tex", keep(EDOMEX) ///
	tex nocons replace bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 1) label nonotes
estat ic
reg d_trips EDOMEX distance distance2 EDOMEXxdistance EDOMEXxdistance2 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)>.1, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC3.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 2) label nonotes
estat ic
reg d_trips EDOMEX distance distance2 distance3 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)>.1, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC3.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 3) label nonotes
estat ic
reg d_trips EDOMEX distance distance2 distance3 distance4 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 EDOMEXxdistance4  sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)>.1, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC3.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 4) label nonotes
estat ic
reg d_trips EDOMEX distance distance2 distance3 distance4 distance5 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 EDOMEXxdistance4 EDOMEXxdistance5 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)>.1, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC3.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 5) label nonotes
estat ic

reg d_fares EDOMEX distance EDOMEXxdistance sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)>.1, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC4.tex", keep(EDOMEX) ///
	tex nocons replace bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 1) label nonotes
estat ic
reg d_fares EDOMEX distance distance2 EDOMEXxdistance EDOMEXxdistance2 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)>.1, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC4.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 2) label nonotes
estat ic
reg d_fares EDOMEX distance distance2 distance3 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)>.1, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC4.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 3) label nonotes
estat ic
reg d_fares EDOMEX distance distance2 distance3 distance4 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 EDOMEXxdistance4  sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)>.1, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC4.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 4) label nonotes
estat ic
reg d_fares EDOMEX distance distance2 distance3 distance4 distance5 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 EDOMEXxdistance4 EDOMEXxdistance5 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM if abs(distance)>.1, vce(cluster ageb_id)
	outreg2 using "$dirtables/TableC4.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 5) label nonotes
estat ic


reg d_price EDOMEX distance EDOMEXxdistance sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM,  vce(cluster CVE_MUN)
	outreg2 using "$dirtables/TableC5.tex", keep(EDOMEX) ///
	tex nocons replace bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 1) label nonotes
estat ic
reg d_price EDOMEX distance distance2 EDOMEXxdistance EDOMEXxdistance2 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM,  vce(cluster CVE_MUN) 
	outreg2 using "$dirtables/TableC5.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 2) label nonotes
estat ic
reg d_price EDOMEX distance distance2 distance3 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM, vce(cluster CVE_MUN)
	outreg2 using "$dirtables/TableC5.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 3) label nonotes
estat ic
reg d_price EDOMEX distance distance2 distance3 distance4 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 EDOMEXxdistance4  sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM, vce(cluster CVE_MUN)
	outreg2 using "$dirtables/TableC5.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 4) label nonotes
estat ic
reg d_price EDOMEX distance distance2 distance3 distance4 distance5 EDOMEXxdistance EDOMEXxdistance2 EDOMEXxdistance3 EDOMEXxdistance4 EDOMEXxdistance5 sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM, vce(cluster CVE_MUN)
	outreg2 using "$dirtables/TableC5.tex", keep(EDOMEX) ///
	tex nocons append bdec(3) tdec(3)  ctitle(" ") ///
	addtext(Controls, Yes, Distance, All, Degree, 5) label nonotes
estat ic




cd "$dirtaximeter"
use "trips_taximeter_with_census.dta", clear
gen wait_min = wait_sec/(60)
su wait_min, d 
replace wait_min=. if wait_min>`r(p99)'
replace wait_min=. if wait_min<`r(p1)'

gen cash=(all_dates>=20781)
gen lnwait=ln(wait_sec/60)
gen lnduration=ln(trip_duration/60)
gen lndistance=ln(dist_meters)

egen municipality_o=group(CVE_ENT_o CVE_MUN_o)
egen municipality_d=group(CVE_ENT_d CVE_MUN_d)
egen ageb_o=group(CVE_ENT_o CVE_MUN_o CVE_AGEB_o)
egen manzana_o=group(CVE_ENT_o CVE_MUN_o CVE_AGEB_o CVE_MZA_o)

gen EDOMEX=(CVE_ENT_o=="15")
gen cash_EDOMEX=cash*EDOMEX
gen lnPOBTOT=ln(POBTOT)

label variable cash "Cash"
label variable cash_EDOMEX "State of Mexico $\times$ Cash"

gen lndistance2 = lndistance * lndistance
gen lnduration2 = lnduration * lnduration


reghdfe lnwait cash cash_EDOMEX if CVE_ENT_o=="15" |  dist_to_edomex<=1000, absorb(municipality_o)  vce(robust)
outreg2 using "$dirtables/Table5.tex", ///
	keep(cash cash_EDOMEX) ///
	replace tex nocons bdec(3) tdec(3)  ctitle(" ")  ///
	addtext(Distance, < 1Km, Controls, N, Region, Municipality) label nonotes
	
	
reghdfe lnwait cash cash_EDOMEX if CVE_ENT_o=="15" |  dist_to_edomex<=2000, absorb(municipality_o) vce(robust)
outreg2 using "$dirtables/Table5.tex", ///
	keep(cash cash_EDOMEX) ///
	append tex nocons bdec(3) tdec(3)  ctitle(" ")  ///
	addtext(Distance, < 2Km, Controls, N, Region, Municipality) label nonotes
	
reghdfe lnwait cash cash_EDOMEX, absorb(municipality_o) vce(robust)
outreg2 using "$dirtables/Table5.tex", ///
	keep(cash cash_EDOMEX) ///
	append tex nocons bdec(3) tdec(3)  ctitle(" ")  ///
	addtext(Distance, All, Controls, N, Region, Municipality) label nonotes 

reghdfe lnwait cash cash_EDOMEX lndistance lnduration GRAPROES count_banks sPEA sVPH_CEL sVPH_INTER sVPH_AUTOM if CVE_ENT_o=="15" |  dist_to_edomex<=1000, absorb(municipality_o)  vce(robust)
outreg2 using "$dirtables/Table5.tex", ///
	keep(cash cash_EDOMEX) ///
	append tex nocons bdec(3) tdec(3)  ctitle(" ")  ///
	addtext(Distance, < 1Km, Controls, Y, Region, Municipality) label nonotes 
	
reghdfe lnwait cash cash_EDOMEX lndistance lnduration GRAPROES count_banks sPEA sVPH_CEL sVPH_INTER sVPH_AUTOM if CVE_ENT_o=="15" |  dist_to_edomex<=2000, absorb(municipality_o) vce(robust)
outreg2 using "$dirtables/Table5.tex", ///
	keep(cash cash_EDOMEX) ///
	append tex nocons bdec(3) tdec(3)  ctitle(" ")  ///
	addtext(Distance, < 2Km, Controls, Y, Region, Municipality) label nonotes 

reghdfe lnwait cash cash_EDOMEX lndistance lnduration GRAPROES count_banks sPEA sVPH_CEL sVPH_INTER sVPH_AUTOM if CVE_ENT_o=="15" |  dist_to_edomex<=1000, absorb(ageb_o)  vce(robust)
outreg2 using "$dirtables/Table5.tex", ///
	keep(cash cash_EDOMEX) ///
	append tex nocons bdec(3) tdec(3)  ctitle(" ")  ///
	addtext(Distance, < 1Km, Controls, Y, Region, AGEB) label nonotes 

	
reghdfe lnwait cash cash_EDOMEX lndistance lnduration if CVE_ENT_o=="15" |  dist_to_edomex<=1000, absorb(manzana_o)   vce(robust)
outreg2 using "$dirtables/Table5.tex", ///
	keep(cash cash_EDOMEX) ///
	append tex nocons bdec(3) tdec(3)  ctitle(" ")  ///
	addtext(Distance, < 1Km, Controls, Y, Region, Block) label nonotes 

	
use "trips_taximeter_with_census.dta", clear
gen wait_min = wait_sec/60
su wait_min, d 
replace wait_min=. if wait_min>=`r(p99)'
replace wait_min=. if wait_min<=`r(p1)'
su wait_min, d 

gen trip_duration_min = trip_duration/60
su trip_duration_min, d 
replace trip_duration_min=. if trip_duration_min>=`r(p99)'
replace trip_duration_min=. if trip_duration_min<=`r(p1)'
su trip_duration_min, d 

gen dist_km = dist_meters/1000
su dist_km, d 
replace dist_km=. if dist_km>=`r(p99)'
replace dist_km=. if dist_km<=`r(p1)'
su dist_km, d 

gcollapse (p25) p25_w=wait_min p25_t=trip_duration_min p25_d=dist_km (median) p50_w=wait_min p50_t=trip_duration_min p50_d=dist_km (mean) mean_w=wait_min mean_t=trip_duration_min mean_d=dist_km (p75) p75_w=wait_min p75_t=trip_duration_min p75_d=dist_km , by(NOM_ENT_o) fast


reshape long p25_ p50_ mean_ p75_, i(NOM_ENT_o) j(Statistic) string
format p* mean*  %6.0g
rename  *_ *
replace Statistic="Distance" if Statistic=="d"
replace Statistic="Time" if Statistic=="t"
replace Statistic="Wait" if Statistic=="w"

rename NOM_ENT_o name
rename Statistic variable
replace name="Mexico City" if name=="Distrito Federal"
replace name="State of Mexico" if name=="Mexico"

replace p25=round(p25,.001)
replace p50=round(p50,.001)
replace mean=round(mean,.001)
replace p75=round(p75,.001)
 
export delimited name variable p25 p50 mean p75 using "$dirtables/TableC6.txt", replace




use "$dirgeolocalized/collapsed_uber_censo_lessthan500mts_Puebla_August.dta", clear
append using "$dirgeolocalized/collapsed_uber_censo_lessthan500mts.dta"
drop if year==2016
drop if  CVE_ENT=="09"
drop ID
egen ID=group(CVE_ENT CVE_MUN CVE_LOC CVE_AGEB CVE_MZA)

keep year ID dist_to_df distance_to_cathedral_card distance_to_cathedral_cash fare_price_card fare_price_cash distance_price_card distance_price_cash driving_mts_card driving_mts_cash distance_mts_o_d_card distance_mts_o_d_cash  trips_card fares_card trips_cash fares_cash dist_to_edomex dist_to_df id ///
CVE_ENT NOM_ENT CVE_MUN NOM_MUN CVE_LOC NOM_LOC CVE_AGEB CVE_MZA x_centroid y_centroid ///
POBTOT VIVTOT REL_H_M PROM_HNV GRAPROES  PNACENT P3YM_HLI PHOG_IND PCON_LIM PEA PEA_M ///
PEA_F P12YM_CASA VPH_PISOTI VPH_1DOR VPH_1CUART VPH_S_ELEC VPH_AGUAFV VPH_NODREN VPH_EXCSA  ///
VPH_SNBIEN VPH_AUTOM VPH_CEL VPH_INTER GRAPROES_M GRAPROES_F max_distance_mts* mean_distance_mts*

egen trips=rowtotal(trips_card trips_cash)
egen fares=rowtotal(fares_card fares_cash)
egen miles=rowtotal(distance_mts_o_d_card distance_mts_o_d_cash)
egen miles_driving=rowtotal(driving_mts_card driving_mts_cash)
egen distance_to_cathedral=rowtotal(distance_to_cathedral_card distance_to_cathedral_cash)

replace miles=miles/1000
replace miles_driving=miles_driving/1000
gen price_original=fares/miles
gen price_driving=fares/miles_driving

egen fares_price=rowtotal(fare_price_card fare_price_cash)
egen distance_price=rowtotal(distance_price_card distance_price_cash)
gen price=(fares_price/distance_price)*1000

gen dist_trip=(distance_price/(1000*trips))
gen fares_trip=fares/trips

gen share_cash=fares_cash/fares

gen temp_share_cash=share_cash if year==2017
bysort ID: egen share_cash2017=max(temp_share_cash)

gen temp_distance_price=distance_price if year==2017
bysort ID: egen distance_price2017=max(temp_distance_price)

keep if POBTOT>0 &  VIVTOT>0
gen temp_trips2017=trips if year==2017
bysort ID: egen trips2017=max(temp_trips2017)
gen trips2017_org=trips2017
replace trips2017=trips2017/POBTOT

gen temp_price2017=price if year==2017
bysort ID: egen price2017=max(temp_price2017)


su price2017, d
replace price2017=. if price2017>=`r(p99)'
replace price2017=. if price2017<=`r(p1)'


foreach var in PNACENT P3YM_HLI PHOG_IND PCON_LIM PEA PEA_M PEA_F P12YM_CASA {
gen s`var'=`var'/POBTOT
}

foreach var in VPH_PISOTI VPH_1DOR VPH_1CUART VPH_S_ELEC VPH_AGUAFV VPH_NODREN VPH_EXCSA VPH_SNBIEN VPH_AUTOM VPH_CEL VPH_INTER {
gen s`var'=`var'/VIVTOT
}

tsset ID year
tsfill, full
by ID: carryforward CVE_ENT CVE_MUN CVE_LOC CVE_AGEB CVE_MZA, replace

foreach var in trips fares {
replace `var'=0 if `var'==.
}

tsset ID year
capture drop d_trips d_fares
gen d_trips=2*(trips-l.trips)/(trips+l.trips)
gen d_fares=2*(fares-l.fares)/(fares+l.fares)
gen d_trips_card=2*(trips_card-l.trips_card)/(trips_card+l.trips_card)
gen d_fares_card=2*(fares_card-l.fares_card)/(fares_card+l.fares_card)
gen d_price=2*(price-l.price)/(price+l.price)
gen d_price_original=2*(price_original-l.price_original)/(price_original+l.price_original)
gen d_price_driving=2*(price_driving-l.price_driving)/(price_driving+l.price_driving)
gen d_miles=2*(distance_price-l.distance_price)/(distance_price+l.distance_price)

gen T1T0=trips*l.trips
gen DW_I=d_trips if d_trips!=2 & d_trips!=-2 & (d_trips!=0 & T1T0>0)
replace DW_I=0 if T1T0==0
gen DW_E=d_trips if d_trips==2 | d_trips==-2 | (d_trips==0 & T1T0>0)
replace DW_E=0 if DW_E==. & DW_I!=.
replace DW_I=0 if DW_I==. & DW_E!=.
replace DW_E=. if d_trips==.
replace DW_I=. if d_trips==.
gen DW=DW_I + DW_E
count if DW!=d_trips & year==2017

gen T1T0_card=trips_card*l.trips_card
gen DW_I_card=d_trips_card if d_trips_card!=2 & d_trips_card!=-2 & (d_trips_card!=0 & T1T0_card>0)
replace DW_I_card=0 if T1T0_card==0
gen DW_E_card=d_trips_card if d_trips_card==2 | d_trips_card==-2 | (d_trips_card==0 & T1T0_card>0)
replace DW_E_card=0 if DW_E_card==. & DW_I_card!=.
replace DW_I_card=0 if DW_I_card==. & DW_E_card!=.
replace DW_E_card=. if d_trips_card==.
replace DW_I_card=. if d_trips_card==.
gen DW_card=DW_I_card + DW_E_card
count if DW_card!=d_trips_card & year==2017

gen T1T0_fares=fares*l.fares
gen DW_I_fares=d_fares if d_fares!=2 & d_fares!=-2 & (d_fares!=0 & T1T0_fares>0)
replace DW_I_fares=0 if T1T0==0
gen DW_E_fares=d_fares if d_fares==2 | d_fares==-2 | (d_fares==0 & T1T0_fares>0)
replace DW_E_fares=0 if DW_E_fares==. & DW_I_fares!=.
replace DW_I_fares=0 if DW_I_fares==. & DW_E_fares!=.
replace DW_E_fares=. if d_fares==.
replace DW_I_fares=. if d_fares==.
gen DW_fares=DW_I_fares + DW_E_fares
replace DW_fares=. if d_fares==.
count if DW_fares!=d_fares & year==2017


gen T1T0_fares_card=fares_card*l.fares_card
gen DW_I_fares_card=d_fares_card if d_fares_card!=2 & d_fares_card!=-2 & (d_fares_card!=0 & T1T0_fares_card>0)
replace DW_I_fares_card=0 if T1T0_card==0
gen DW_E_fares_card=d_fares_card if d_fares_card==2 | d_fares_card==-2 | (d_fares_card==0 & T1T0_fares_card>0)
replace DW_E_fares_card=0 if DW_E_fares_card==. & DW_I_fares_card!=.
replace DW_I_fares_card=0 if DW_I_fares_card==. & DW_E_fares_card!=.
replace DW_E_fares_card=. if d_fares_card==.
replace DW_I_fares_card=. if d_fares_card==.
gen DW_fares_card=DW_I_fares_card + DW_E_fares_card
replace DW_fares_card=. if d_fares_card==.
count if DW_fares_card!=d_fares_card & year==2017


keep if year==2018		 
		 
merge 1:1 CVE_ENT CVE_MUN CVE_LOC CVE_AGEB CVE_MZA using "$dirgeolocalized/denue_bancos.dta"
drop if _merge==2
drop _merge
replace count_banks=0 if count_banks==.
gen bank=(count_banks!=0 & count_banks!=.)

egen ageb_id=group(CVE_ENT CVE_MUN CVE_AGEB)

gen treatment=(CVE_ENT=="21" | CVE_ENT=="29")
drop if treatment==.

label variable treatment "Puebla"

foreach var in sVPH_INTER GRAPROES sPEA sVPH_CEL sVPH_AUTOM {
bysort CVE_ENT: egen m`var'=mean(`var')
}

tsset ID year

capture drop cem*
cem count_banks GRAPROES sVPH_CEL sVPH_INTER sVPH_AUTOM trips2017 price2017, treatment(treatment) showbreaks  

	
reg d_trips treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table7.tex", keep(treatment) ///
	tex nocons replace bdec(3) tdec(3)  ctitle("$\Delta Trips$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, All) label nonotes
	
reg DW_I treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table7.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Trips_I$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, Intensive) label nonotes

reg DW_E treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table7.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Trips_E$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, Extensive) label nonotes
	
reg d_fares treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table7.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Fares$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, All) label nonotes
	
reg DW_I_fares treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table7.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Fares_I$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, Intensive) label nonotes

reg DW_E_fares treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table7.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Fares_E$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, Extensive) label nonotes
	

reg d_trips_card treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table7.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Trips^{card}$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, All) label nonotes
	
reg d_fares_card treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table7.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Fares^{card}$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, All) label nonotes
	
reg d_price treatment [iweight=cem_weights]
	outreg2 using "$dirtables/Table7.tex", keep(treatment) ///
	tex nocons append bdec(3) tdec(3)  ctitle("$\Delta Price$") ///
	addtext(Estimator, CEM, Rule, Sturges, Margin, All) label nonotes
	
